home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue41 / Patterns / HVExtTimeKeeper.PAS next >
Encoding:
Pascal/Delphi Source File  |  1998-11-19  |  1014 b   |  49 lines

  1. unit HVExtTimeKeeper;
  2.  
  3. interface
  4.  
  5. uses
  6.   HVTimeKeeper2;
  7.  
  8. type
  9.   TExtTimeKeeper = class(TTimeKeeper)
  10.   private
  11.     function GetNowStr: string;
  12.     function GetTodayName: string;
  13.   public
  14.     property NowStr: string read GetNowStr;
  15.     property TodayName: string read GetTodayName;
  16.   end;
  17.  
  18. // A new access function is only needed if the public
  19. // interface has been extended
  20. function TimeKeeper: TExtTimeKeeper;
  21.  
  22. implementation
  23.  
  24. uses
  25.   SysUtils;
  26.  
  27. { TTimeKeeper }
  28.  
  29. function TExtTimeKeeper.GetNowStr: string;
  30. begin
  31.   Result := SysUtils.DateTimeToStr(Self.Now);
  32. end;
  33.  
  34. function TExtTimeKeeper.GetTodayName: string;
  35. begin
  36.   Result := SysUtils.LongDayNames[SysUtils.DayOfWeek(Self.Date)]
  37. end;
  38.  
  39. // Simplified functional interface
  40.  
  41. function TimeKeeper: TExtTimeKeeper;
  42. begin
  43.   Result := TExtTimeKeeper(TExtTimeKeeper.Instance);
  44. end;
  45.  
  46. initialization
  47.   // Register ourselves as the new TTimeKeeper class
  48.   TExtTimeKeeper.OverrideSingletonClass(TTimeKeeper, TExtTimeKeeper);
  49. end.